Many imaging system are adapted to automatically focus on an object of interest, and to maintain that focus as the object moves with respect to the imaging system. The autofocus methods discussed below are typical of machine inspection systems for testing/inspecting liquid-crystal and flat-panel displays, printed circuit boards, MEMS-based circuits, semiconductor devices/wafers, biomedical specimens, etc. These system are typically focused by adjusting the spacing between the image detector (e.g., camera) and the object of interest. The following discussion describes autofocus systems that adjust the level of focus by moving the image detector relative to the object of interest, but may also be applied to systems that employ adjustable lens configurations. One such system is described in U.S. patent application Ser. No. 10/348,940 to Enachescu and Belikov, entitled “Methods and Systems Employing Infrared Thermography for Defect Detection and Analysis,” filed Jan. 22, 2003, which is incorporated herein by reference.
Autofocus methods for machine inspection systems can be broadly separated into two main categories: position sensing and content analysis. Position sensing methods measure the distance between the image detector and object and focus the image detector accordingly. In typical inspection systems, position-sensing autofocus methods maintain a constant distance between the object and the image detector. Position-sensing autofocus systems typically include a feedback control system that moves the object and/or the imaging system to maintain the correct distance. The LaserTrack™ Laser Tracking AutoFocus from Teletrac, Inc., of Santa Barbara, Calif., is an example of a position-sensing autofocus system.
There are several disadvantages of position sensing methods. First, the distance maintained by the autofocus control system must be calibrated to coincide with the best-focus position of the image detector. Second, only a small portion of the object of interest is used to measure the distance, so other parts of the object may not be optimally focused. Third, distance measurement may be unsuitable for some objects; for example, laser-based distance sensing may not work if the object has holes.
Content-analysis methods achieve and maintain the best-focus position by processing images acquired by the imaging system. Systems employing such methods apply a focus-measure function (FMF) to each of a series of images taken at various focus positions. The resulting collection of focus measures is then analyzed to determine the best-focus position. Content-analysis methods overcome many of the disadvantages associated with position-sensing methods because content-analysis methods rely upon images, and not some secondary indicia of focus distance, to calculate the best-focus position.
In typical inspection systems, FMFs derive a focus measure based in part on the distance between the image detector and the object. Plotting focus measures as a function of distance produces a focus-measure plot, the peaks of which may be correlated with position to find the best-focus position. FMFs preferably have the following major properties:                1. unimodality, or the existence of a single peak, maximum or minimum, within the range of interest.        2. accuracy, or coincidence, of the peak with the best-focus position;        3. reproducibility, or a sharp peak;        4. range (e.g., the focus range over which the FMF will unambiguously determine the direction to the best-focus position);        5. general applicability, or the ability to work on different classes of images;        6. insensitivity to changes in parameters that do not impact focus, such as changes in mean image intensity;        7. video-signal compatibility, or the ability to use the same image signals utilized for image analysis; and        8. speed: it should be possible to calculate the FMF rapidly.For additional background information regarding FMFs, see “Focusing Technique,” by Subbarao, Choi and Nikzad, (Journal of Optical Engineering, pp. 2824-2836, November 1993), and U.S. Pat. No. 5,932,872 to Price, both of which are incorporated herein by reference. Portions of those references are summarized below.        
A focused image, represented by I(x,y) at point (x,y), is defined as the total light energy incident on the entrance pupil (e.g., the camera aperture) during one exposure period from the object point along the direction corresponding to (x,y). A point-spread function (PSF) defines the blur (or spread) corresponding to a single point in the image I(x,y) when the image is out of focus. Equation 1 provides a realistic model of a PSF:
                              h          ⁡                      (                          x              ,              y                        )                          =                  {                                                                                                                                        1                                                  π                          ⁢                                                                                                          ⁢                                                      R                            2                                                                                              ⁢                                                                                          ⁢                      if                      ⁢                                                                                          ⁢                                              x                        2                                                              +                                          y                      2                                                        ≤                  R                                                                                                      0                  ⁢                                                                          ⁢                  otherwise                                                                                        (        1        )            where R is the radius of the blur circle, and the ideal focus corresponds to a PSF of h(x,y)=δ(x,y), where δ(x,y) is the delta function. The blur radius is given by:
                    R        =                              Ds            2                    ⁢                      (                                          1                f                            -                              1                u                            -                              1                s                                      )                                              (        2        )            where D is the aperture diameter, f is the focal length, s is the distance between the lens plane and the imaging surface of the image detector (e.g., the focal-plane array), and u is the distance between the lens plane and the object plane. In this formula, R can be positive (if the imaging surface is behind the focused image) or negative (if the imaging surface is in front of the focused image). In practical imaging systems one can change either u (by moving the image detector) or s (by moving the lens). For the ideally focused image, this formula gives R→0.
The Fourier transform of PSF h(x,y) is termed an “Optical Transfer Function” (OTF). The OTF attenuates high spatial frequencies (sharpness) within the image I(x,y) more significantly for larger radii R of the blur circle; in other words, larger blur circles imply blurrier images. One can therefore measure sharpness and focus based on the high spatial frequency content of an image. One can further develop a focus measure indicative of the high spatial frequency content of an image by applying a high-pass filter (linear or nonlinear) to each image I(x,y) and taking the average intensity value (or average energy) of the filtered image. A series of images, each taken at a unique focus distance, can be similarly analyzed to provide focus measures for various focus levels. These focus measures can then be analyzed to find the best-focus position.
A number of references describe means of obtaining focus measures suitable for identifying a best-focus position for various imaging systems, objects of interest, and levels of magnification. These references include: U.S. Pat. Nos. 5,231,443; 5,932,872; 6,037,892; 6,201,619; 6,463,214; 6,151,415; 6,373,481; and 6,222,588; and an article entitled “Selecting the Optimal Focus Measure for Autofocusing and Depth-from-Focus,” by Subbaro and Tyan, published in IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 20, No. 8, pp. 864-870, August 1998): each of these documents is incorporated herein by reference. A conventional system that uses a computer-based autofocusing method is ProbeMagic™ system from TNP Instruments Inc. (Carson, Calif.). That system performs autofocusing so-called Roberts cross gradient for a FMF. This implementation moves the focus motor up and down to determine best focus. One disadvantage of this implementation is that it uses a single filter (Roberts) that cannot be adapted to a variety of images. In addition, the implementation does not include adaptive autofocusing, i.e. the autofocusing is not performed in real-time.
Many of the available methods are not generally applicable to different classes of images, a significant shortcoming for imaging systems that look at different kinds of images. Furthermore, adaptive motion-control algorithms are usually implemented either electronically or in embedded microprocessors, and are consequently difficult to reconfigure for different types of images. There is therefore a need for a fast, precise autofocus method that is easily adapted for use with different imaging systems and different types of images.